package com.example.demo.pojos;

import javax.persistence.*;
import java.util.Objects;

@Entity
public class Picture {
    private int pictureId;
    private String pictureRoute;
    private Product cp;

    @Id
    @Column(name = "picture_id", nullable = false)
    public int getPictureId() {
        return pictureId;
    }

    public void setPictureId(int pictureId) {
        this.pictureId = pictureId;
    }

    @Basic
    @Column(name = "picture_route", nullable = true, length = 255)
    public String getPictureRoute() {
        return pictureRoute;
    }

    public void setPictureRoute(String pictureRoute) {
        this.pictureRoute = pictureRoute;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Picture picture = (Picture) o;
        return pictureId == picture.pictureId &&
                Objects.equals(pictureRoute, picture.pictureRoute);
    }

    @Override
    public int hashCode() {
        return Objects.hash(pictureId, pictureRoute);
    }

    @ManyToOne
    @JoinColumn(name = "picture_id1", referencedColumnName = "picture_id", nullable = false)
    public Product getCp() {
        return cp;
    }

    public void setCp(Product cp) {
        this.cp = cp;
    }
}
